<?php
header ( "Content-Type:text/html;charset=utf-8" );
/****测试速度****/
include_once ("debug.php");
$starttime = microtime_float ();
echo "start:" . $starttime . '<br>';

/***头部信息****/
$config = "config";
$public = "public";
$kernel = "kernel";

define ( 'CONFIG', realpath ( $config ) . DIRECTORY_SEPARATOR );
define ( 'KERNEL', realpath ( $kernel ) . DIRECTORY_SEPARATOR );
define ( 'PUBLICS', realpath ( $public ) . DIRECTORY_SEPARATOR );
define ( 'LIBS', realpath ( KERNEL . 'libs' ) . DIRECTORY_SEPARATOR );
unset ( $config, $libs, $public );

require_once (CONFIG . "config.php");
if (file_exists ( '_install' . EXT )) {
	return include 'install' . EXT;
}

require_once (KERNEL . 'kernel.php');

$KERNEL = new Kernel ( );
$KERNEL->run ();

$class = $KERNEL->instance ();
$module = $KERNEL->module ();
$action = $KERNEL->action ();

$err = new Error ( );
$err->my_error_handler ();

//根据URL路由
$url = new Url ( );
$module = $url->getModule () ? $url->getModule () : MODULE_DEFAULT;
$action = $url->getAction () ? $url->getAction () : ACTION_DEFAULT;
$values = $url->getValues ();
define ( "BASEPATH", $url->site () );
define ( "WEBPATH", BASEPATH . "index.php" );

//生成缓存文件
if (CACHE_OPEN) {
	$cache = new cache ( CACHE_PATH, CACHE_PAGE_TTL );
	if (! $cache->read_cache ()) {
		$html = new $module ( );
		$html->$action ();
		$cache->create_cache ();
	}
} else {
	$html = new $module ( );
	$html->$action ();
}

//测试速度
$endtime = microtime_float ();
echo "<br>end:" . $endtime . '<br>';
$time = $starttime - $endtime;
echo "时间差:" . $time;

?>